package com.bawei.mvp.View;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.bawei.mvp.Presenter.initPresenter;

/**
 * create by ertu
 * create on 2021/7/26
 * description
 */
public abstract class BoosFragment<P extends initPresenter> extends Fragment implements initFragment,initView {
    protected P mPresenter;
    View view;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return view = inflater.inflate(bandLayout(),container,false);//---------------Fragment布局

    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView();//---------------Fragment视图id
        initDate();//---------------Fragment控制数据
    }

    //---------------FragmentID属性
    @Override
    public <T extends View> T findByids(int id) {
        return view.findViewById(id);
    }

    @Override
    public void tostLayout(String smg) {
        Toast.makeText(getActivity(), smg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void haidLayout() {

    }

    @Override
    public void showLayout() {

    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null)
        {
            mPresenter.dires();
        }
    }
}
